import java.util.*;


class TreeNode{
    public char val;
    public TreeNode left;
    public TreeNode right;
    public TreeNode(char val){
        this.val = val;
    }
}
public class Main0824 {
    public static int i = 0;
    public static TreeNode CreateBinaryTree(String str){


        TreeNode root = null;

        if (str.charAt(i) != '#'){
            root = new TreeNode(str.charAt(i));
            i++;
            root.left = CreateBinaryTree(str);

            root.right = CreateBinaryTree(str);

        }else{
            i++;
        }
        return root;
    }
    public static void inOrder(TreeNode root){
        if (root == null){
            return ;
        }
        inOrder(root.left);

        System.out.print(root.val + " ");


        inOrder(root.right);

    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);


        while (scanner.hasNextLine()) {
            String s = scanner.nextLine();
            TreeNode treenode = CreateBinaryTree(s);
            inOrder(treenode);
        }
    }
}
